package com.bcxk.common;

import java.io.Serializable;

public class Respond<T> implements Serializable {

    private boolean ok;
    private String error;
    private T data;

    public boolean isOk() {
        return ok;
    }

    public void setOk(boolean ok) {
        this.ok = ok;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> Respond<T> ok(T data) {
        Respond<T> respond = new Respond<>();
        respond.setOk(true);
        respond.setError(null);
        respond.setData(data);
        return respond;
    }
    public static <T> Respond<T> ok() {
        Respond<T> respond = new Respond<>();
        respond.setOk(true);
        respond.setError(null);
        return respond;
    }

    public static <T> Respond<T> error(String error) {
        Respond<T> respond = new Respond<>();
        respond.setOk(false);
        respond.setError(error);
        respond.setData(null);
        return respond;
    }


}
